<!DOCTYPE html>
<?php
//header("Location:dashboard.php");
setcookie("username","eghie",0);
if (isset($_COOKIE['username'])){
//    echo '<META HTTP-EQUIV="Refresh" Content="0; URL=dashboard.php">';
//    exit;
    header("Location:dashboard.php");
}else{
    include('global.php');
    if(isset($_POST['username']) &&  isset($_POST['password'])){
        $username = $_POST['username'];
        $password = md5($_POST['password']);
        $sql = "select * from tbl_user where username='$username' and password='$password'";
        $result=dbresultODBC($sql);
        $jumlah=odbc_num_rows($result);
        if($jumlah > 0){
                $r = odbc_fetch_array($result,0);
                setcookie("username",$username,0);	
                setcookie("password",$password,0);

//                echo '<META HTTP-EQUIV="Refresh" Content="0; URL=dashboard.php">';
//                exit;
                header("Location:dashboard.php");
        }else{
                $pesan = "Hak Akses Ditolak";
        }
    }
}
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>PT. SRIBOGA FLOUR MILL</title>
        
    <!--CSS-->
    <link href="jquery/bootstrap/login/bootstrap-3.1.0.min.css" rel="stylesheet" id="bootstrap-css">
    <link rel="stylesheet" type="text/css" href="jquery/bootstrap/login/login.css" media="screen, projection, tv" />
    <!--JQUERY-->
    
<!--    <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="jquery/bootstrap/login/bootstrap.min.js"></script>
    <script type="text/javascript" src="jquery/bootstrap/login/login.js"></script>-->
    </head>
    <body>
        <div class="container">
	<div class="login-container">
            <div id="output"></div>
            <div class="avatar"></div>
            <div class="form-box">
                <form action="" method="post">
                    <input name="username" type="text" placeholder="username">
                    <input name="password" type="password" placeholder="password">
                    <button class="btn btn-info btn-block login" type="submit">Login</button>
                </form>
            </div>
        </div>
        </div>
    
    </body>
</html>
